d71c19e1ed951fe2cbd1a5511c69745511f7126a,xwiki-platform-tag/plugin/skinx/src/main/java/com/xpn/xwiki/plugin/skinx/CssResourceSkinExtensionPlugin.java,CssResourceSkinExtensionPlugin,getLink,#String#XWikiContext#,61

Before Change


    public String getLink(String documentName, XWikiContext context)
    {
        String url = "";
        try {
            // If the current user has access to Main.WebHome, we will use this document in the URL
            // to serve the js resource. This way, the resource can be efficiently cached, since it has a
            // common URL for any page.
            if (context.getWiki().getRightService().hasAccessLevel("view", context.getUser(), "Main.WebHome", context)) {
                url = context.getWiki().getURL("Main.WebHome", "ssx", "resource=" + documentName, context);
            }
        } catch (XWikiException e) {
            // do nothing here, we'll fold back just after.
        }
        if (url.equals("")) {
            // If we could not have an URL with Main.WebHome, we use the context document.
            url = context.getDoc().getURL("ssx", "resource=" + documentName, context);
        }
        return "<link rel='stylesheet' type='text/css' href='" + url + "'/>";
    }

    @Override

After Change


        // If the current user has access to Main.WebHome, we will use this document in the URL
        // to serve the css resource. This way, the resource can be efficiently cached, since it has a
        // common URL for any page.
        try {
            String page = context.getWiki().getDefaultWeb(context) + "." + context.getWiki().getDefaultPage(context);
            if (!context.getWiki().getRightService().hasAccessLevel("view", context.getUser(), page, context)) {
                page = context.getDoc().getFullName();
            }
            String url =
                context.getWiki().getURL(page, "ssx",
                    "resource=" + documentName + parametersAsQueryString(documentName, context), context);
            result = "<link rel='stylesheet' type='text/css' href='" + url + "'/>";
        } catch (XWikiException e) {
            // Do nothing here; we can't access the wiki, so don't link to this resource at all.
        }
        return result;
    }

    /**